package Source

import org.apache.flink.streaming.api.scala._

//定义样例类
case class SensorReading(id: String, timeStamp: Long, temperature: Double)

object SourceFromCollection {
  def main(args: Array[String]): Unit = {
    //创建执行环境
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    //从集合中读取数据
    val dataList = (List(
      SensorReading("sensor_1", 1547718199, 35.8),
      SensorReading("sensor_6", 1547718201, 15.4),
      SensorReading("sensor_7", 1547718202, 6.7),
      SensorReading("sensor_10", 1547718205, 38.1)
    ))
    //从集合中读取数据
    val stream1 = env.fromCollection(dataList)
    //d读取的数据类型不限
    //    val stream1 = env.fromElements(dataList)
    //    val stream2 = env.fromElements(1.0,"aa",1)
    stream1.print()
    //    stream2.print()
    env.execute()
  }
}
